import httpUtil from "@/utils/httpUtil";
import logApi from "@/api/logApi.js";

const sendLoginSms = (mobile, callBack) => {
	send(mobile, 'mobilelogin', callBack)
}

const send = (mobile, event, callBack) => {
	let params = {
		mobile,
		event
	}
	let logParams = {
		mobile,
		event,
	}
	logApi.addLog('准备发送登录短信,' + JSON.stringify(logParams))
	httpUtil.post('/api/rf/sendSms', params, res => {
		logParams.res = res
		logApi.addLog('发送登录短信,发送成功返回信息：' + JSON.stringify(logParams))
		if (callBack) {
			callBack(res)
		}
	}, err => {
		logParams.err = err
		logApi.addLog('发送登录短信,发生失败返回信息：' + JSON.stringify(logParams))
	})
}

export default {
	sendLoginSms
}